package progress.exa4;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class ObjectOutputStreamStudy {

    public static void main(String[] args) throws IOException {
        objectOutputStreamStudy();
    }

    /**
     * 对象输出流学习
     */
    public static void objectOutputStreamStudy() throws IOException {
        ObjectOutputStream objOutputStream = null;
        try {
            objOutputStream = new ObjectOutputStream(new FileOutputStream("四郎"));
            List<String> objList = new ArrayList<>();
            objList.add("我是四郎，我爱麻子");
            objOutputStream.writeObject(objList);
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            if(objOutputStream!=null) {
                objOutputStream.close();
            }
        }
    }

}
